package com.heima.wemedia.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("api/v1/channel")
public class WmChannelsController {

    @Autowired
    WmChannelsService wmChannelsService;

    /**
     * 频道列表
     * @return
     */
    @GetMapping("channels")
    public ResponseResult channels(){
        //select * from wm_channels order by ord
        List<WmChannel> list = wmChannelsService.list(Wrappers.<WmChannel>lambdaQuery().orderByAsc(WmChannel::getOrd));
        return ResponseResult.okResult(list);
    }
}
